package com.class05;


import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

/**
 * @ClassDescription:
 * @JdkVersion: 17
 * @Author: yxy
 * @Created: 2023/11/29 17:06
 */
public class HelloServlet extends HttpServlet {
    @Override//编写一个Servlet类，用来处理用户的请求
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        String parameter = req.getParameter("method");
        if (parameter.equals("add")) {
            req.getSession().setAttribute("msg", "helloadd");
        } else if (parameter.equals("delete")) {
            req.getSession().setAttribute("msg", "hellodelete");
        }
        req.getRequestDispatcher("/WEB-INF/jsp/hello.jsp").
                forward(req, resp);

    }
}
